/**
 * 
 * Copyright (C) 2011 Cody Stoutenburg . All rights reserved.
 *
 *       This program is free software; you can redistribute it and/or
 *       modify it under the terms of the GNU Lesser General Public License
 *       as published by the Free Software Foundation; either version 2.1
 *       of the License, or (at your option) any later version.
 *
 *       This program is distributed in the hope that it will be useful,
 *       but WITHOUT ANY WARRANTY; without even the implied warranty of
 *       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *       GNU Lesser General Public License for more details.
 *
 *       You should have received a copy of the GNU Lesser General Public License
 *       along with this program; if not, write to the Free Software
 *       Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
 * 
 */
package ca.usherbrooke.model;

import org.newdawn.slick.geom.Rectangle;

import ca.usherbrooke.tools.GUID;
import ca.usherbrooke.tools.position.Vector2D;

/**
 * @author Cody Stoutenburg
 * 
 */
public abstract class BaseModel extends GUID implements IBaseModel {
	private static final long serialVersionUID = 1L;

	protected String name;

	// We use a rectangle2D to represent the character size and the area
	// that the character occupy
	protected final Rectangle size;

	public BaseModel(String name, Rectangle position) {
		this.size = position;
		this.name = name;
	}

	@Override
	public String getName() {
		return this.name;
	}

	@Override
	public Vector2D getPosition() {
		return new Vector2D(size.getX(), size.getY());
	}

	@Override
	public Vector2D getCenterPosition() {
		return new Vector2D(size.getCenterX(), size.getCenterY());
	}

	@Override
	public Rectangle getSize() {
		return new Rectangle(size.getX(), size.getY(), size.getWidth(),
				size.getHeight());
	}

	@Override
	public void setPosition(Vector2D position) {
		this.size.setX(position.getX().floatValue());
		this.size.setY(position.getY().floatValue());
	}

	protected void resize(float width, float height) {
		this.size.setWidth(width);
		this.size.setHeight(height);
	}
}
